//
//  ShangHuLeiXingViewController.m
//  跨界收
//
//  Created by Allen on 2018/11/11.
//  Copyright © 2018年 gztx. All rights reserved.
//

#import "ShangHuLeiXingViewController.h"
#import "WanShanQianYueViewController.h"
#import "ShopCategoryView.h"

@interface ShangHuLeiXingViewController ()
@property (nonatomic, strong) ShopCategoryView *categoryView;
@property (nonatomic, strong) NSArray *categoryArray;
@property (nonatomic, assign) NSInteger stag;
@end

@implementation ShangHuLeiXingViewController
- (void)createShopCategoryView
{
    _categoryArray = @[@" 公司 ",@" 个体工商户 ",@" 个人 "];
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 30)];
    titleLabel.textColor = [UIColor lightGrayColor];
    titleLabel.text = @"   请选择商户类型";
    titleLabel.font = [UIFont systemFontOfSize:16.0];
    titleLabel.textAlignment = NSTextAlignmentLeft;
    [self.view addSubview:titleLabel];
    NSArray *titleArray = @[@"企业经营",@"个体工商户",@"个人"];
    CGFloat height = 10 + titleArray.count*80 +10;
    _categoryView = [[ShopCategoryView alloc] initWithFrame:CGRectMake(0, 30, SCREEN_WIDTH, height)];
    _stag = 0;
    WeakSelf;
    _categoryView.selectBlock = ^(NSInteger tag) {
        weakSelf.stag = tag-1000;
        NSLog(@"%d",weakSelf.stag);
    };
    [self.view addSubview:_categoryView];
    
    //获取状态栏的rect
    CGRect statusRect = [[UIApplication sharedApplication] statusBarFrame];
    //获取导航栏的rect
    CGRect navRect = self.navigationController.navigationBar.frame;
    UIButton *goBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT-50-statusRect.size.height-navRect.size.height, SCREEN_WIDTH, 50.0)];
    goBtn.backgroundColor = [UIColor cz_colorWithHex:0x239fdb];
    [goBtn setTitle:@"下一步" forState:UIControlStateNormal];
    [goBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [goBtn addClickTargetBlock:^(UIButton *sender) {
        WanShanQianYueViewController *vc = [[WanShanQianYueViewController alloc] initWithNibName:@"WanShanQianYueViewController" bundle:nil];
        vc.category = weakSelf.categoryArray[weakSelf.stag];
        NSLog(@"%@",weakSelf.categoryArray[weakSelf.stag]);
        [weakSelf.navigationController pushViewController:vc animated:YES];
    }];
    [self.view addSubview:goBtn];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"商户类型";
    [self createShopCategoryView];
    // Do any additional setup after loading the view from its nib.
}

@end
